/*
 * Copyright 2010 Gaurav Saxena
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.gwtstructs.gwt.client.widgets.list;

import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;

public class BulletListPanel extends ListPanel{
	public static enum BULLET_STYLE_TYPE {
		CIRCLE("circle"),
		DISC("disc"),
		SQUARE("square"),
		NONE("none");
		private String styleType;
		public String toString() {
			return styleType;
		}
		BULLET_STYLE_TYPE(String styleType) {
			this.styleType = styleType;
		}
	};
	public BulletListPanel() {
		super(Document.get().createULElement());
	}
	public void setBulletSize(int bulletSize) {
		DOM.setStyleAttribute(getElement(), "fontSize", bulletSize + "px");
	}
	public void setBulletColor(String htmlColor) {
		DOM.setStyleAttribute(getElement(), "color", htmlColor);
	}
	public void setBulletImageUrl(String url) {
		DOM.setStyleAttribute(getElement(), "listStyleImage", "url(\"" + url + "\")");
		setBulletStyleType(BULLET_STYLE_TYPE.NONE);
	}
	public void setBulletStyleType(BULLET_STYLE_TYPE type) {
		DOM.setStyleAttribute(getElement(), "listStyleType", type.toString());
	}
	public void setBulletSize(Widget w, int bulletSize) {
		assert super.getWidgetIndex(w) > -1 : "Widget not found";
		DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "fontSize", bulletSize + "px");
	}
	public void setBulletColor(Widget w, String htmlColor) {
		assert super.getWidgetIndex(w) > -1 : "Widget not found";
		DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "color", htmlColor);
	}
	public void setBulletImageUrl(Widget w, String url) {
		assert super.getWidgetIndex(w) > -1 : "Widget not found";
		DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "listStyleImage", "url(\"" + url + "\")");
		setBulletStyleType(w, BULLET_STYLE_TYPE.NONE);
	}
	public void setBulletStyleType(Widget w, BULLET_STYLE_TYPE type) {
		assert super.getWidgetIndex(w) > -1 : "Widget not found";
		DOM.setStyleAttribute((Element) w.getElement().getParentElement(), "listStyleType", type.toString());
	}
}